package com.investment.action;

import com.investment.bean.Vip;
import com.investment.service.VipService;
import com.investment.util.DaoException.DbException;
import com.investment.util.Response.Response;
import com.investment.util.tools.Tool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import java.util.Date;
import java.util.Map;

import static org.springframework.beans.BeanUtils.copyProperties;

/**
 * Created by veicth on 17/2/25.
 */

@Controller
@RequestMapping(value = "vip")
public class VipController {

    @Autowired
    private VipService vipService;
    //private Vip vip;

    @RequestMapping(value ="/insert" ,method= RequestMethod.GET)
    public Response<Vip> insert(){
//        String id = params.get("id");
//        String name = params.get("name");
//        String password = params.get("password");
//        String mobile = params.get("mobile");
//        String is_valid = params.get("is_valid");
//        String create_at = params.get("create_at");
//        String update_at = params.get("update_at");
//        String level = params.get("level");
//        String time = System.currentTimeMillis().toString();
        Vip bean  = new Vip();
        try{

            bean.setId(Tool.getUUID32());
            bean.setCreate_at("2017-02-26 23:28:00");
            bean.setUpdate_at("2017-02-26 23:28:00");
            bean.getIs_valid(1);
            bean.setName("wwq1");
            bean.setPassword("123456");
            bean.setMobile("15217609876");
            bean.setLevel(1);
            vipService.insert(bean);

        }catch(Exception ex){
            System.out.print(ex);
        }
        //return "login/success";
        return Response.success(bean);
    }
    @RequestMapping(value = "/find" ,method = RequestMethod.GET)
    public void find() throws DbException {
        Vip people = vipService.find("6c245ad24d21430293ba057e76a21d16");
        //System.out.print(people.getName());
//        return new ModelAndView("login/test").addObject("message",people);
        System.out.println("111");
    }
}
